home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #3 / Amiga Plus CD - 2002 - No. 03.iso / AmiSoft / Dev / Lang / Nano.lha / nano / prog / viewtext.n < prev   
Encoding:
Text File  |  2002-11-18  |  680 b   |  40 lines

  1. #include <file.h>
  2.  
  3. string filen[256]; string s[256]; string ch[2];
  4. int i; int maxlines;
  5.  
  6. maxlines = 20;
  7.  
  8. print "viewtext", /n;
  9. input "filename: " filen;
  10. if filen = "";
  11.     exit;
  12. endif;
  13. print /n2;
  14.  
  15. fopen 1, filen, "r";
  16. if _file = FILE_OPEN;
  17.     print "can't open file!", /n;
  18.     exit;
  19. endif;
  20.  
  21. _file = FILE_OK; i = 0;
  22. while _file = FILE_OK;
  23.     fread 1 s;
  24.     if _file != FILE_EOF;
  25.        print s; inc i;
  26.     endif;
  27.     if i = 20;
  28.         ch = "";
  29.         inputch "[RETURN: next lines, r: rewind] " ch;
  30.         ucase ch;
  31.         if ch = "R";
  32.             frewind 1;
  33.         endif;
  34.  
  35.         i = 0; print /n;
  36.     endif;
  37. wend;
  38. fclose 1;
  39. print /n, "[end of file ", "'", filen, "']", /n;
  40.